<?php
/**
 * 指标下达模块
 * 
 */
class targetsAction extends apiAction {
	
	/**
	 * 任务量查看，按月份查询
	 */
	public function index(){
		$user = getUserSession();
		
		switch ($user['roleId']) {
			case 1 : $defaultType = 'city';			break;
			case 3 : $defaultType = 'microArea';	break;
			case 4 : $defaultType = 'people';		break;
			case 7 : $defaultType = 'people';		break;
			default : $defaultType = 'people';
		}
		
		$type = I('type', $defaultType);
		$month= I('month', date('Y-m'));
		
		if($type == 'city'){
			$data = D('target')->getCityTargets($month);
		}
		
		if($type == 'microArea'){
			$data = D('target')->getMicroAreaTargets($month, FALSE);
		}
		
		if($type == 'people'){
			$data = D('target')->getPepoleTargets($month, FALSE);
		}
		
		$this->assign('roleId', $user['roleId']);
		$this->assign('month',$month);
		$this->assign('type',$type);
		$this->assign('page',$data['page']);
		$this->assign('list',$data['list']);
			
		$this->display();
	}
	
	/**
	 * 重点产品信息查询
	 */
	public function point(){
        $list = M('model')->alias('m')
            ->field(
                array(
                    'm.*',
                    'b.name'=>'brandName',
                )
            )
            ->join(C('DB_PREFIX')."brand as b on b.id=m.brandId")
            ->where(array('m.isImportant'=>1,'m.status'=>1))
            ->select();
        $this->assign('list',$list);
       // var_dump($list);
        $this->display();
            
	}
}

/* End of file targetsAction.class.php */